{extend name="base" /}
{block name="content"}
<script src="__STATIC__/public/My97DatePicker/WdatePicker.js"></script>
<div class="g-main">
    <div class="m-main-title">
        <div class="m-container-fluid">
            <a href="{:url('index/welcome')}"><i class="icon icon-home"></i>首页</a>
            <span class="icon-angle-right"></span>
            <span>系统</span>
            <span class="icon-angle-right"></span>
            <span>分销管理</span>
            <span class="icon-angle-right"></span>
            <span>用户分配</span>
            <a class="u-flush"><i class="icon-repeat"></i></a>
        </div>
    </div>
    <div class="m-main-content">
        <div class="m-container">
            <div class="m-form">
                <form class="layui-form" action="">
                    <table class="m-table">
                        <thead>
                        <tr>
                            <th colspan="2">用户分配</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td width="15%"><label for="title">用户名称<em>*</em></label></td>
                            <td width="50%">{$memberData.nickname}</td>

                        </tr>
                        <tr>
                            <td><label for="">选择商家<em>*</em></label></td>
                            <td>
                                <div class="lay-select">
                                    <select name="business_id">
                                        <option value="0">请选择商家</option>
                                        {foreach name="businessData" item="v"}
                                            <option value="{$v.id}">{$v.business_name}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </td>
                        </tr>

                    </table>
                    <div class="m-form-btn"><input type="hidden" name="member_id" value="{$memberData.id}"><button lay-submit lay-filter="formDemo" class="u-btn">确定提交</button></div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="extrajs"}
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form,
            layer = layui.layer;

        //监听提交
        form.on('submit(formDemo)', function(data){
            var business_id = data.field.business_id;
            var member_id = data.field.member_id;
            if (business_id == '0'){
                layer.alert("请选择商家");
                return false;
            }
            $.post('/manage/business/saveDistribution',{
                business_id :business_id,
                member_id:member_id
            },function (res) {
                if (res.status){
                    layer.alert(res.message);
                }else{
                    layer.alert(res.message,function (index) {
                        layer.close(index);
                        window.location.href='/manage/business/memberDistribution'
                    });
                }
            });
            return false;
        });
    });
</script>
{/block}